#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
@author: DDD
@file: main.py
@time: 2022/5/16 9:52
"""
# _*_ coding: utf-8 _*_
# @Author : zzg
# motto   : 有教无类，陪伴呵护

from flask import Flask, render_template, request, jsonify, flash, redirect, Response
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate, MigrateCommand
from datetime import datetime

app = Flask(__name__)

manager = Manager(app)
# 设置连接数据
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:yzxa1234.@124.221.93.136:3308/flask'

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

app.config['SECRET_KEY'] = 'adsasdasdzxcasfadsf'

db = SQLAlchemy(app)

# 第一个参数是Flask的实例，第二个参数是Sqlalchemy数据库实例
Migrate(app, db)

# manager是Flask-Script的实例，这条语句在flask-Script中添加一个db命令
manager.add_command('db', MigrateCommand)


class Infos(db.Model):
    # __table_args__ = {'extend_existing': True}
    __tablename__ = 'db_infos'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(50), nullable=True)
    codecoll = db.Column(db.String(10), nullable=True)
    echnology = db.Column(db.String(200), nullable=True)
    direction = db.Column(db.String(200), nullable=True)
    price = db.Column(db.String(50), nullable=True)
    create_time = db.Column(db.DateTime, default=datetime.now)

    def __repr__(self):
        return "<Role %s>" % self.name


@app.route('/')
def index():
   return "haha"


if __name__ == '__main__':
    manager.run()
